<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //函数
        let arr = [1, 5, 16, 66, 68]
        let res = arr.filter(value => value > 20)
        console.log(res)
        let res1 = arr.map((value, index, array) => {
            console.log(value)
            console.log(index)
            console.log(array)
            return value + 20
        })
        console.log(res1)
        arr4 = [123, "aaa", "bbb", "nn", 567]
        let arr5 = arr4.slice(2)
        console.log(arr5)
        let arr6 = [1, 2, 3, 4, 5]
        let arr7 = arr6.reduce((previousValue, currentValue) => {
            return previousValue - currentValue
        })
        console.log(arr7)
        let arr8 = [12, 5, 7, 1, -1, 6]
        let arr9 = arr8.reduce((previousValue, currentValue) => {
            return previousValue + currentValue
        })
        console.log(arr9)
        for (let i = 0; i < arr.length; i++) {
            console.log(arr[i])
        }
        for (item of arr) {
            console.log(item)
        }
        for (index in arr) {
            console.log(arr[index])
        }
        //对象
        //1.大括号
        let obj={
            name:"jane",
            age:25,
            height:188
        }
        obj.say=function(a){
            console.log(a)
        }
        obj.say("hi")
        obj.sayHello= a => console.log(a)
        
        obj.sayHello("你好")
        console.log(obj.height)
        //2.new
        let obj1=new Object()
        obj1.name="bob"
        obj1.age=18
        obj1.height=185
        obj1.weight=72
        obj1.gender="male"
        console.log(obj1)
        console.log(obj1.name)
        //3.构造函数（es5及其之前）
        function Person(name,age,height,weight,gender){
            this.name=name
            this.age=age
            this.height=height
            this.weight=weight
            this.gender=gender
            this.tomorrow=function(a){
                console.log(a)
            }
        }
        let p=new Person("hames",20,75,187,"male","你好")
        p.tomorrow("see you")
        console.log(p.name)
        console.log(p)
        //4.Class
        class Student{
            constructor(name,age){
                console.log("构造函数被调用了")
                this.name=name
                this.age=age
            }
            sayHello(){
                console.log("hello,class")
            }
        }
        let s=new Student("zhangsan",20)
        console.log(s)
        s.sayHello()
        let s1=new Student("james",18)
        console.log(s1)
        let s2=s.__proto__===s1.__proto__
        console.log(s2)
        // 5.对象常用的方法
        let product={
            name:"iphone17",
            price:10000,
            color:"鼠尾草绿"
        }
        console.log(Object.keys(product))
        console.log(Object.values(product))
        console.log(Object.entries(product))
        let entries=Object.entries(product)
        for(item of entries){
            console.log(item)
        }
        for(index in entries){
            console.log(entries[index])
        }
    </script>
</body>

</html>